package com.youseu.taoliving.commodity.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.youseu.common.valid.EnumValidate;
import com.youseu.common.valid.SaveGroup;
import com.youseu.common.valid.UpdateGroup;
import com.youseu.common.valid.UpdateIsShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 家居品牌
 * 
 * @author tao
 * @email tao@gmail.com
 * @date 2024-07-31 21:27:30
 */
@Data
@TableName("commodity_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 * 需要分组校验 添加商品时id必须为空
	 * 修改商品必须携带id
	 */
	@TableId
	@NotNull(groups = {UpdateGroup.class, UpdateIsShowGroup.class},message = "修改需要指定id")
	@Null(groups = {SaveGroup.class},message = "添加不能指定id")
	private Long id;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名不能为空",groups = {SaveGroup.class,UpdateGroup.class})
	private String name;
	/**
	 * logo
	 */
	@NotBlank(message = "logo不能为空",groups = {SaveGroup.class})
	@URL(message = "logo必须是合法的url",groups = {SaveGroup.class,UpdateGroup.class})
	private String logo;
	/**
	 * 说明
	 */
	@NotBlank(message = "描述不能为空",groups = {SaveGroup.class,UpdateGroup.class})
	private String description;
	/**
	 * 显示
	 */
	@NotNull(message = "显示状态不能为空",groups = {SaveGroup.class,UpdateGroup.class,UpdateIsShowGroup.class})
	@EnumValidate(values = {0,1},groups = {SaveGroup.class,UpdateGroup.class,UpdateIsShowGroup.class})//自定义校验注解
	private Integer isshow;
	/**
	 * 检索首字母
	 */
	@NotBlank(message = "检索字母不能为空",groups = {SaveGroup.class})
	@Pattern(regexp="^[a-zA-Z]$",message = "检索字母必须是一个字母",groups = {SaveGroup.class,UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(message = "排序不能为空",groups = {SaveGroup.class})
	@Min(value = 0,message = "排序需要大于等于0",groups = {SaveGroup.class,UpdateGroup.class})
	private Integer sort;

}
